/*
 * Academic License - for use in teaching, academic research, and meeting
 * course requirements at degree granting institutions only.  Not for
 * government, commercial, or other organizational use.
 *
 * File: SMO_Arctan_FOC.c
 *
 * Code generated for Simulink model 'SMO_Arctan_FOC'.
 *
 * Model version                  : 2.5
 * Simulink Coder version         : 9.8 (R2022b) 13-May-2022
 * C/C++ source code generated on : Wed Oct  9 21:48:48 2024
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "SMO_Arctan_FOC.h"
#include "rtwtypes.h"
#include "SMO_Arctan_FOC_Speed_Control.h"
#include "SMO_Arctan_FOC_SMO_FOC.h"
#include "SMO_Arctan_FOC_Schedul_10msTask.h"
#include "SMO_Arctan_FOC_private.h"
#include "rt_nonfinite.h"

int_T SMO_Arctan_FOC_GlobalTID[3];
const rtTimingBridge *SMO_Arctan_FOC_TimingBrdg;
MdlrefDW_SMO_Arctan_FOC_T SMO_Arctan_FOC_MdlrefDW;

/* Block signals (default storage) */
B_SMO_Arctan_FOC_c_T SMO_Arctan_FOC_B;

/* Block states (default storage) */
DW_SMO_Arctan_FOC_f_T SMO_Arctan_FOC_DW;

/* Declare global variables for system: model 'SMO_Arctan_FOC' */
real32_T SMO_Arctan_FOC_arg_Target_Speed;/* '<Root>/Target_Speed' */
const real32_T *SMO_Arctan_FOC_arg_Iabc;/* '<Root>/Iabc' */
real32_T *SMO_Arctan_FOC_arg_Vabc_PU;  /* '<Root>/Vabc_PU' */

/* System initialize for referenced model: 'SMO_Arctan_FOC' */
void SMO_Arctan_FOC_Init(void)
{
  /* SystemInitialize for S-Function (fcgen): '<S1>/Function-Call Generator3' incorporates:
   *  SubSystem: '<S1>/Speed_Control'
   */
  SMO_Arctan_F_Speed_Control_Init();

  /* End of SystemInitialize for S-Function (fcgen): '<S1>/Function-Call Generator3' */

  /* SystemInitialize for S-Function (fcgen): '<S1>/Function-Call Generator4' incorporates:
   *  SubSystem: '<S1>/SMO_FOC'
   */
  SMO_Arctan_FOC_SMO_FOC_Init();

  /* End of SystemInitialize for S-Function (fcgen): '<S1>/Function-Call Generator4' */
}

/* Enable for referenced model: 'SMO_Arctan_FOC' */
void SMO_Arctan_FOC_Enable(void)
{
  /* Enable for S-Function (fcgen): '<S1>/Function-Call Generator5' incorporates:
   *  SubSystem: '<S1>/Schedul_10msTask'
   */
  SMO_Arc_Schedul_10msTask_Enable();

  /* End of Enable for S-Function (fcgen): '<S1>/Function-Call Generator5' */

  /* Enable for S-Function (fcgen): '<S1>/Function-Call Generator4' incorporates:
   *  SubSystem: '<S1>/SMO_FOC'
   */
  SMO_Arctan_FOC_SMO_FOC_Enable();

  /* End of Enable for S-Function (fcgen): '<S1>/Function-Call Generator4' */
}

/* Disable for referenced model: 'SMO_Arctan_FOC' */
void SMO_Arctan_FOC_Disable(void)
{
  /* Disable for S-Function (fcgen): '<S1>/Function-Call Generator5' incorporates:
   *  SubSystem: '<S1>/Schedul_10msTask'
   */
  SMO_Ar_Schedul_10msTask_Disable();

  /* End of Disable for S-Function (fcgen): '<S1>/Function-Call Generator5' */

  /* Disable for S-Function (fcgen): '<S1>/Function-Call Generator3' incorporates:
   *  SubSystem: '<S1>/Speed_Control'
   */
  SMO_Arcta_Speed_Control_Disable();

  /* End of Disable for S-Function (fcgen): '<S1>/Function-Call Generator3' */

  /* Disable for S-Function (fcgen): '<S1>/Function-Call Generator4' incorporates:
   *  SubSystem: '<S1>/SMO_FOC'
   */
  SMO_Arctan_FOC_SMO_FOC_Disable();

  /* End of Disable for S-Function (fcgen): '<S1>/Function-Call Generator4' */
}

/* Output and update for referenced model: 'SMO_Arctan_FOC' */
void SMO_Arctan_FOC_step(real32_T arg_Target_Speed, real32_T arg_Iabc[3],
  real32_T arg_Vabc_PU[3])
{
  SMO_Arctan_FOC_arg_Target_Speed = arg_Target_Speed;
  SMO_Arctan_FOC_arg_Iabc = arg_Iabc;
  SMO_Arctan_FOC_arg_Vabc_PU = arg_Vabc_PU;

  /* Delay: '<S1>/Delay' */
  SMO_Arctan_FOC_B.Delay = SMO_Arctan_FOC_DW.Delay_DSTATE;
  if (rtmIsSampleHit(2, 0)) {
    /* S-Function (fcgen): '<S1>/Function-Call Generator5' incorporates:
     *  SubSystem: '<S1>/Schedul_10msTask'
     */
    SMO_Arctan_FOC_Schedul_10msTask();

    /* End of Outputs for S-Function (fcgen): '<S1>/Function-Call Generator5' */
  }

  if (rtmIsSampleHit(1, 0)) {
    /* S-Function (fcgen): '<S1>/Function-Call Generator3' incorporates:
     *  SubSystem: '<S1>/Speed_Control'
     */
    SMO_Arctan_FOC_Speed_Control();

    /* End of Outputs for S-Function (fcgen): '<S1>/Function-Call Generator3' */
  }

  /* S-Function (fcgen): '<S1>/Function-Call Generator4' incorporates:
   *  SubSystem: '<S1>/SMO_FOC'
   */
  SMO_Arctan_FOC_SMO_FOC();

  /* End of Outputs for S-Function (fcgen): '<S1>/Function-Call Generator4' */

  /* Update for Delay: '<S1>/Delay' incorporates:
   *  UnitDelay: '<S28>/Unit Delay'
   */
  SMO_Arctan_FOC_DW.Delay_DSTATE = SMO_Arctan_FOC_DW.UnitDelay_DSTATE_no;
}

/* Model initialize function */
void SMO_Arctan_FOC_initialize(const char_T **rt_errorStatus, const
  rtTimingBridge *timingBridge, int_T mdlref_TID0, int_T mdlref_TID1, int_T
  mdlref_TID2)
{
  RT_MODEL_SMO_Arctan_FOC_T *const SMO_Arctan_FOC_M =
    &(SMO_Arctan_FOC_MdlrefDW.rtm);

  /* Registration code */

  /* initialize non-finites */
  rt_InitInfAndNaN(sizeof(real_T));

  /* setup the global timing engine */
  SMO_Arctan_FOC_GlobalTID[0] = mdlref_TID0;
  SMO_Arctan_FOC_GlobalTID[1] = mdlref_TID1;
  SMO_Arctan_FOC_GlobalTID[2] = mdlref_TID2;
  SMO_Arctan_FOC_TimingBrdg = timingBridge;

  /* initialize error status */
  rtmSetErrorStatusPointer(SMO_Arctan_FOC_M, rt_errorStatus);
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
